<template>
  <el-container class="index-con">
    <el-aside :class="showClass">
      <leftNav></leftNav>
    </el-aside>
    <el-container class="main-con">
      <el-header class="index-header">
        <navCon></navCon>
      </el-header>
      <el-main clss="index-main">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
import navCon from '../components/navCon.vue'
import leftNav from '../components/leftNav.vue'
export default {
  name: 'Home',
  data () {
    return {
      showClass: 'asideshow',
      showType: false,
      user: JSON.parse(window.sessionStorage.getItem('user'))
    }
  },
  components: {
    navCon,
    leftNav
  },
  computed: {
    routes () {
      return this.$store.state.routes
    }
  },
  methods: {
    created () {
      this.$root.Bus.$on('toggle', value => {
        if (value) {
          this.showclass = 'asideshow'
        } else {
          setTimeout(() => {
            this.showclass = 'aside'
          }, 300)
        }
      })
    },
    goChat () {
      this.$router.push('/chat')
    },
    commandHandler (cmd) {
      if (cmd === 'logout') {
        this.$confirm('此操作将注销登录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.getRequest('/logout')
          window.sessionStorage.removeItem('user')
          this.$store.commit('initRoutes', [])
          this.$router.replace('/')
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          })
        })
      } else if (cmd === 'userinfo') {
        this.$router.push('/hrinfo')
      }
    }
  }
}
</script>

<style>
  .index-con {
    height: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  .aside {
    width: 64px !important;
    height: 100%;
    background-color: #334157;
    margin: 0px;
  }
  .asideshow {
    width: 240px !important;
    height: 100%;
    background-color: #334157;
    margin: 0px;
  }
  .index-header,
  .index-main {
    padding: 0px;
    border-left: 2px solid #333;
  }
    .homeRouterView {
        margin-top: 10px;
    }

    .homeWelcome {
        text-align: center;
        font-size: 30px;
        font-family: 华文行楷;
        color: #409eff;
        padding-top: 50px;
    }

    .homeHeader {
        background-color: #409eff;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0px 15px;
        box-sizing: border-box;
    }

    .homeHeader .title {
        font-size: 30px;
        font-family: 华文行楷;
        color: #ffffff
    }

    .homeHeader .userInfo {
        cursor: pointer;
    }

    .el-dropdown-link img {
        width: 48px;
        height: 48px;
        border-radius: 24px;
        margin-left: 8px;
    }

    .el-dropdown-link {
        display: flex;
        align-items: center;
    }
</style>
